import sys

# 登陆验证

user = "a"
password = "1"
money = float(10000.00)
# # 输入初始界面
print("=" * 12, "存取款系统", "=" * 14)
countname = 1
name = input("请输入用户名：")
while name != user:
    print("用户名输入错误，请重新输入")
    if countname < 3:
        name = input("请输入用户名：")
        countname += 1
    else:
        print("已连续错误三次，登陆禁止")
        sys.exit()
else:
    countpswd = 1
    pswd = input("请输入密码：")
    while pswd != password:
        print("请注意您还有 ", 3-countpswd, "次机会")
        if countpswd <3:
            pswd = input("请输入密码：")
            countpswd += 1
        else:
            print("已连续错误三次，登陆禁止")
            sys.exit()
    else:
        while True:  # 选择后不退出
            # 输入初始界面
            print("=" * 12, "欢迎登陆系统", "=" * 14)
            print("{0:1} {1:13} {2:15}".format(" ", "1.查询余额", "2.存款"))
            print("{0:1} {1:13} {2:15}".format(" ", "3.取款,", "4.退出"))
            print("=" * 40)

            key = input("请输入对应的选择：")
            # 根据键盘判断并操作
            if key == "1":
                print("=" * 12, "查询余额", "=" * 14)
                print("{0:10} {1:10}".format("您的余额为：", str(round(money, 2))))
                input("按回车继续：")
            elif key == "2":
                print("=" * 12, "存款", "=" * 14)
                try:
                    addm = float(input("请输入存款金额："))
                    if addm < 0:
                        print("存款金额不能为负！")
                    else:
                        print("{0:10} {1:10}".format("原账户余额为：", str(round(money, 2))))
                        money += float(addm)
                        print("{0:10} {1:10}".format("新账户余额为：", str(round(money, 2))))
                except:
                    print("请输入金额数字！")
                input("按回车继续：")
            elif key == "3":
                print("=" * 12, "取款", "=" * 14)
                try:
                    addm = float(input("请输入取款金额："))
                    if addm > money:
                        print("账户余额不足！")
                    elif addm < 0:
                        print("存款金额不能为负！")
                    else:
                        print("{0:10} {1:10}".format("原账户余额为：", str(round(money, 2))))
                        money -= float(addm)
                        print("{0:10} {1:10}".format("新账户余额为：", str(round(money, 2))))
                except:
                    print("请输入金额数字！")
                input("按回车继续：")
            elif key == "4":
                print("=" * 12, "再见", "=" * 14)
                break
            else:
                print("=" * 12, "无效键盘输入", "=" * 14)
